//对象简介
import {a_tank_actionproperty, army_anctions} from "../commdata";

export class army{
    name:string="";
    x:number=0;
    y:number=0;
    ratewidth:number=a_tank_actionproperty.ratewidth/1.5;
    rateheight:number=a_tank_actionproperty.rateheight/1.5;
    isSelect:boolean=false;
    currantactions=army_anctions;
    img:any;

    constructor(_name:string,_x:number,_y:number) {
        this.name=_name;
        this.x=_x;
        this.y=_y;
        this.img=new Image();
        this.img.src = this.currantactions[0].imgsrc;
    }

    drawarmy=(ptctx: any)=>{

        if(this.isSelect==true) {

            ptctx.beginPath();
            ptctx.strokeStyle="green";
            ptctx.clearRect(this.x-5, this.y, this.ratewidth+2, this.rateheight+2);
            ptctx.rect(this.x-5, this.y, this.ratewidth+2, this.rateheight+2);
            ptctx.stroke();
            ptctx.drawImage(this.img, 1, 1, this.img.width, this.img.height, this.x, this.y, this.ratewidth, this.rateheight);

        }
        else {
            ptctx.drawImage(this.img, 0, 0, this.img.width, this.img.height, this.x, this.y, this.ratewidth, this.rateheight);
        }
    }

}